#ifndef CORE_OBJECT_H
#define CORE_OBJECT_H

#include <core/core.h>


namespace yam3d
{

namespace core
{

/**
 * Object class to be used as core class for each kajak3d engine class.
 * Object class overloads standard new and delete functionality. Memory 
 * allocations and deallocations of new and delete operations are done 
 * from core::MemoryManager. 
 * Object class also provides functionality for internal object reference
 * counting. Refecence counting can be done using addRef and releaseRef
 * methods.
 * 
 * @ingroup core
 * @author Mikko Romppainen (mikko.romppainen@ureainteractive.com)
 *
 * @version	0.0.1	25.06.2011	MikkoR	Draft	 Initial revision.
 */
class Object
{
public:

        /**
         * Default constructor.
         * Creates an object and sets ref count to 0.
         */
        Object(const char* const name);

	/**
	 * Class destructor.
	 */
        virtual ~Object();

	/** 
	 * Increments ref count.
	 */
	inline void addRef()
	{
		assert( m_numOfRefs >= 0 );
		++m_numOfRefs;
	}

	/** 
         * Decrements ref count.
	 * @return Returns current ref count.
	 */
        inline int releaseRef()
	{
		assert( m_numOfRefs > 0 );
		return --m_numOfRefs;
	}

	/**
	 * Returns current ref count.
	 */
	inline int getRefCount() const
	{
		return m_numOfRefs;
	}

private:
        /**
         * Default constructor.
         * Creates an object and sets ref count to 0.
         */
        Object();

	// Member variables
	int m_numOfRefs;

	// Non-allowed methods (declared but not defined anywhere, result link error if used)
        Object( const Object& );
        Object& operator=( const Object& );
};


}

}

#endif
